package com.atguigu.gulimall.order.vo;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * @ClassName OrderConfirmVo
 * @Description TODO
 * @Detail detail
 * @Author MyPC
 * @Date 2020/7/18
 * @Version 1.0
 */
public class OrderConfirmVo {

    //收货地址Vo  存储在ums_member_receive_address表中
    @Setter @Getter
    List<MemberAddressVo> address;

    //支付方式,可在页面写死

    //所有选中的购物项
    @Setter @Getter
    List<OrderItemVo> items;

    //发票信息

    //优惠券信息
    @Setter @Getter
    Integer integration;

    //防重令牌
    @Setter @Getter
    String orderToken;

    //商品库存
    @Setter @Getter
    private Map<Long,Boolean> stocks;

    //s商品件数
    public Integer getCount(){
        Integer count=0;
        if(items !=null){
            for (OrderItemVo item : items) {
                count+=item.getCount();
            }
        }
        return count;
    }

    //订单总额
//    BigDecimal total;
    public BigDecimal getTotal(){
        BigDecimal sum=new BigDecimal("0");
        if(items !=null){
            for (OrderItemVo item : items) {
                sum=sum.add(item.getPrice().multiply(new BigDecimal(item.getCount())));
            }
        }
        return sum;
    }

    //应付价格
//    BigDecimal payPrice;
    public BigDecimal getPayPrice(){
        return getTotal();
    }

}
